package com.scalar.forecast.forecastEntry.actions;

import com.scalar.forecast.ForecastExtendedAction;
import com.scalar.forecast.forecastEntry.actionCommands.ForecastEntrySearchActionCommandFactory;
import com.scalar.forecast.actionCommands.ActionCommand;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionForm;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * User: Sujan Kumar
 * Date: Feb 11, 2005
 * Time: 11:49:11 AM
 */
public class ForecastEntrySearchAction extends ForecastExtendedAction
{
    public ActionForward executeRequest( ActionMapping mapping,
                                                      ActionForm form,
                                                      HttpServletRequest request,
                                                      HttpServletResponse response) throws Exception
    {
        ActionForward actionForward = mapping.findForward ( "searchPage" );
        String action = request.getParameter ( "action" );
        
        try
        {
            if ( action == null )
            {
                action = ACTION_NEW;
            }
            ActionCommand actionCommand = ForecastEntrySearchActionCommandFactory.getActionCommand( action );
            if ( actionCommand != null)
            {
                actionForward = actionCommand.execute( mapping, form, request, response );
            }
        }
        catch( Exception e )
        {
            e.printStackTrace();
        }
        return actionForward;
    }
}